﻿#include "OperationFactory.h"
#include <QStringList>
#include "OperationAdd.h"
#include "OperationSub.h"
#include "OperationMul.h"
#include "OperationDiv.h"

//OperationFactory::OperationFactory()
//{

//}

Operation* OperationFactory::createOperate(QString op)
{
    Operation* oper = nullptr;
    QStringList operateList;
    operateList << "+" << "-" << "*" << "/";
    switch (operateList.indexOf(op)) {
    case 0:
        oper = new OperationAdd();
        break;
    case 1:
        oper = new OperationSub();
        break;
    case 2:
        oper = new OperationMul();
        break;
    case 3:
        oper = new OperationDiv();
        break;
    default:
        break;
    }
    return oper;
}
